from numpy.random import randint
import matplotlib.pyplot as plt
import seaborn as sns
from tabulate import tabulate
from PIL import Image

x = randint(0, 256, size=(3, 5))
print(tabulate(x, tablefmt='grid'))
plt.imshow(x, vmin=0, vmax=255, cmap='gray')
plt.colorbar()
plt.axis('off')
plt.show()

# vmin=0, vmax=255
# square=Ture : 用正方块显示每一个像素
# annot=True  : 每一个像素上显示对应的数字
# fmt='.0f'   : 小数点后面取0位
sns.heatmap(x, vmin=0, vmax=255, square=True, annot=True, fmt='.0f', cmap='gray')
# labeltop=True     :  在图像上端显示x轴
# labelbottom=False :  把图像下端显示的数字去除
# bottom=False      :  把图像下端显示的数轴线段去除
# rotation=0        :  把x和y轴的数字都调节为竖向显示
plt.tick_params(labeltop=True, labelbottom=False, bottom=False, rotation=0)
plt.show()
'''a = Image.open('dog.jpg')
# pixle = a.load()
w, h = a.size
for x in range(w):
    for y in range(h):
        r, _, _ = pixle[x, y]
        pixle[x, y] = r, 0, 0
a = a.resize((w*10, h*10), resample=Image.NEAREST)
a.show()'''
